<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * This is a sample module for PyroCMS
 *
 * @author 		Jerel Unruh - PyroCMS Dev Team
 * @website		http://unruhdesigns.com
 * @package 	PyroCMS
 * @subpackage 	Sample Module
 */
class Admin extends Admin_Controller
{

	public function __construct()
	{
		parent::__construct();
		
		$this->load->model('dataman_m');
		$this->load->model('general_m');
		$this->lang->load('dataman');
		
		$this->show_entity->changeStatusOfShowOutOfBid();
		
		$this->template->set_partial('shortcuts', 'admin/partials/shortcuts')
						->append_metadata(js('admin.js', 'dataman'))
						->append_metadata(js('jquery.form.js', 'dataman'))
						->append_metadata(js('helper.js', 'dataman'))
						->append_metadata(css('admin.css', 'dataman'))
						->append_metadata(css('jquery-ui.css', 'dataman'))
						;
	}

	public function index()
	{
		$this->template->title($this->module_details['name'])->build('admin/items', $this->data);
	}
	
	function general(){
		$route = $this->uri->segment(4,'');
		$this->template->append_metadata(js('general.js', 'dataman'));
		
		switch($route){
		/*	
			case 'music':
				$this->data->items = $this->general_m->index();
				$this->template->title($this->module_details['name'])
						->build('admin/general/index', $this->data);
				break;
			case 'music_add':
				$this->data = null;
				$this->template->title($this->module_details['name'])
						->build('admin/general/music_add', $this->data);
				break;	
			case 'music_save':
				$this->general_m->music_save();
				break;
			case 'music_edit':
				$this->data->item = $this->general_m->music_edit();
				$this->template->title($this->module_details['name'])
						->build('admin/general/music_edit', $this->data);
				break;	
			case 'music_delete':
				$this->general_m->music_delete();
				break;	
		*/		
			default:
			case 'country':
				$this->data->items = $this->general_m->country();
				$this->template->title($this->module_details['name'])
						->build('admin/general/country', $this->data);
				break;
			case 'country_add':
				$this->data = null;
				$this->template->title($this->module_details['name'])
						->build('admin/general/country_add', $this->data);
				break;
			case 'country_save':
				$this->general_m->country_save();
				break;
			case 'country_edit':
				$this->data->item = $this->general_m->country_edit();
				$this->template->title($this->module_details['name'])
						->build('admin/general/country_edit', $this->data);
				break;
			case 'country_delete':
				$this->general_m->country_delete();
				break;	
			
			case 'city':
				$this->data->items = $this->general_m->city();
				$this->template->title($this->module_details['name'])
						->build('admin/general/city', $this->data);
				break;
			case 'city_add':
				$this->data->array_items = $this->general_m->city_add();
				$this->template->title($this->module_details['name'])
						->build('admin/general/city_add', $this->data);
				break;
			case 'city_save':
				$this->general_m->city_save();
				break;
			case 'city_edit':
				$this->data->array_items = $this->general_m->city_edit();
				$this->template->title($this->module_details['name'])
						->build('admin/general/city_edit', $this->data);
				break;
			case 'city_delete':
				$this->general_m->city_delete();
				break;	
		}
	}	

	function seller(){
		$route = $this->uri->segment(4,'');
		$this->template->append_metadata(js('seller.js', 'dataman'));
		
		$this->load->model('seller_m');
		switch($route){
			default:
			case 'activated':
				$this->data->items = $this->seller_m->list_activated();
				$this->template->title($this->module_details['name'])
						->build('admin/seller/index', $this->data);
				break;
			case 'confirmed':
				$this->data->items = $this->seller_m->list_confirmed();
				$this->template->title($this->module_details['name'])
						->build('admin/seller/index', $this->data);
				break;	
			case 'pending':
				$this->data->items = $this->seller_m->list_pending();
				$this->template->title($this->module_details['name'])
						->build('admin/seller/index', $this->data);
				break;	
			case 'search':
				$this->data->items = $this->seller_m->search();
				$this->template->title($this->module_details['name'])
						->build('admin/seller/index', $this->data);
				break;	
			case 'activate':
				$this->seller_m->activate();
				break;	
			case 'deactivate':
				$this->seller_m->deactivate();
				break;		
			case 'delete':
				$this->seller_m->delete();
				break;
			case 'edit':
				$this->data->items = $this->user_entity->init('id', $_POST['user_id']);
				$this->load->view('admin/seller/edit_information',$this->data);
				break;
			case 'submit_information':
				$this->seller_m->submit_information();
				break;
			case 'add':
				$this->load->view('admin/seller/add_account_information',$this->data = null);
				break;
			case 'submit_add_account':
				$this->seller_m->submit_add_account();
				break;
			case 'user_information':
				$this->data->items = $this->user_entity->init('id', $_POST['user_id']); 
				$this->load->view('admin/seller/user_information',$this->data);
				break;
		}
	}
	
	function buyer(){
		$route = $this->uri->segment(4,'');
		$this->template->append_metadata(js('buyer.js', 'dataman'));
		
		$this->load->model('buyer_m');
		switch($route){
			default:
			case 'activated':
				$this->data->items = $this->buyer_m->list_activated();
				$this->template->title($this->module_details['name'])
						->build('admin/buyer/index', $this->data);
				break;
			case 'confirmed':
				$this->data->items = $this->buyer_m->list_confirmed();
				$this->template->title($this->module_details['name'])
						->build('admin/buyer/index', $this->data);
				break;	
			case 'pending':
				$this->data->items = $this->buyer_m->list_pending();
				$this->template->title($this->module_details['name'])
						->build('admin/buyer/index', $this->data);
				break;	
			case 'search':
				$this->data->items = $this->buyer_m->search();
				$this->template->title($this->module_details['name'])
						->build('admin/buyer/index', $this->data);
				break;	
			case 'activate':
				$this->buyer_m->activate();
				break;	
			case 'deactivate':
				$this->buyer_m->deactivate();
				break;		
			case 'delete':
				$this->buyer_m->delete();
				break;
			case 'edit':
				$this->data->items = $this->user_entity->init('id', $_POST['user_id']);
				$this->load->view('admin/buyer/edit_information',$this->data);
				break;
			case 'submit_information':
				$this->buyer_m->submit_information();
				break;
			case 'add':
				$this->load->view('admin/buyer/add_account_information',$this->data = null);
				break;
			case 'submit_add_account':
				$this->buyer_m->submit_add_account();
				break;
			case 'user_information':
				$this->data->items = $this->user_entity->init('id', $_POST['user_id']); 
				$this->load->view('admin/buyer/user_information',$this->data);
				break;
		}
	}
	
	function show(){
		$route = $this->uri->segment(4,'');
		$this->template->append_metadata(js('show.js', 'dataman'));
		
		$this->load->model('show_m');
		switch($route){
			default:
			case 'opening':
				$this->data->items = $this->show_m->list_opening();
				$this->template->title($this->module_details['name'])
						->build('admin/show/index', $this->data);
				break;
			case 'pending':
				$this->data->items = $this->show_m->list_pending();
				$this->template->title($this->module_details['name'])
						->build('admin/show/index', $this->data);
				break;	
			case 'closed':
				$this->data->items = $this->show_m->list_closed();
				$this->template->title($this->module_details['name'])
						->build('admin/show/index', $this->data);
				break;	
			case 'cancelled':
				$this->data->items = $this->show_m->list_cancelled();
				$this->template->title($this->module_details['name'])
						->build('admin/show/index', $this->data);
				break;	
			case 'search':
				$this->data->items = $this->show_m->search();
				$this->template->title($this->module_details['name'])
						->build('admin/show/index', $this->data);
				break;		
			case 'change_show_status':
				$this->show_m->change_show_status();
				break;	
			case 'delete':
				$this->show_m->delete();
				break;
			case 'show_information':
				$this->data->items = $this->show_entity->init('id', $_POST['show_id']);
				$this->load->view('admin/show/show_information',$this->data);
				break;	
			case 'edit':
				$this->data->items = $this->show_entity->init('id', $_POST['show_id']);
				$this->load->view('admin/show/edit_show_information',$this->data);
				break;
			case 'submit_information':
				$this->show_m->submit_information();
				break;
			case 'bid':
				$this->data->items = $this->show_m->bid();
				$this->template->title($this->module_details['name'])
						->build('admin/show/bid', $this->data);
				break;
			case 'change_bid_status':
				$this->show_m->change_bid_status();
				break;
			case 'delete_bid':
				$this->show_m->delete_bid();
				break;
			case 'bid_information':
				$this->data->items = $this->show_m->bid_information();
				$this->load->view('admin/show/bid_information',$this->data);
				break;
			case 'edit_bid':
				$this->data->items = $this->show_m->edit_bid();
				$this->load->view('admin/show/edit_bid_information',$this->data);
				break;
			case 'submit_edit_bid':	
				$this->show_m->submit_edit_bid();
				break;
		}		
	}
	
	function bid(){
		$route = $this->uri->segment(4,'');
		$this->template->append_metadata(js('bid.js', 'dataman'));
		
		$this->load->model('bid_m');
		switch($route){
			default:
			case 'bidding':
				$this->data->items = $this->bid_m->bidding();
				$this->template->title($this->module_details['name'])
						->build('admin/bid/index', $this->data);
				break;
			case 'processing':
				$this->data->items = $this->bid_m->processing();
				$this->template->title($this->module_details['name'])
						->build('admin/bid/index2', $this->data);
				break;
			case 'completed':
				$this->data->items = $this->bid_m->completed();
				$this->template->title($this->module_details['name'])
						->build('admin/bid/index2', $this->data);
				break;
			case 'search':
				$this->data->items = $this->bid_m->search();
				$this->template->title($this->module_details['name'])
						->build('admin/bid/index', $this->data);
				break;
			case 'change_pay_status':
				$this->bid_m->change_pay_status();
				break;
			case 'email':
				$this->data->items = $this->bid_m->email();
				$this->template->title($this->module_details['name'])
						->build('admin/bid/email', $this->data);
				break;
			case 'compose':
				$this->data->items = $this->bid_m->compose();
				$this->template->title($this->module_details['name'])
						->append_metadata( $this->load->view('fragments/wysiwyg', $this->data, TRUE) )
						->build('admin/bid/compose');
				break;
			case 'submit_email_compose':
				$this->bid_m->submit_email_compose();
				break;
		}	
	}
	
	function statistics(){
		$route = $this->uri->segment(4,'');
		$this->template->append_metadata(js('statistics.js', 'dataman'));
		
		$this->load->model('statistics_m');
		switch($route){
			default:
			case 'shows':
				$this->data->items = $this->statistics_m->show();
				$this->template->title($this->module_details['name'])
						->build('admin/statistics/show', $this->data);
				break;
			case 'successfully_transaction_shows':
				$this->data->items = $this->statistics_m->successfully_transaction_shows();
				$this->template->title($this->module_details['name'])
						->build('admin/statistics/successfully_transaction_shows', $this->data);
				break;
			case 'summary_report':	
				$this->data->items = $this->statistics_m->summary_report();
				$this->template->title($this->module_details['name'])
						->build('admin/statistics/summary_report', $this->data);
				break;
		}	
	}
	
	
	
	
	
	
	
	
}
